function getImgUrl(img) {
	if (img == '') {
		return '/api/base/noneDefault.jpg'
	} else {
		return img
	}
}

function getTimeFormat(time, type) {
	if (!time) {
		return '----'
	}
	let nowTime = new Date(Number(time))
	let Year = nowTime.getFullYear()
	let month =
		nowTime.getMonth() + 1 < 10
			? '0' + (nowTime.getMonth() + 1)
			: nowTime.getMonth()
	let date = nowTime.getDate() < 9 ? '0' + nowTime.getDate() : nowTime.getDate()
	let hour =
		nowTime.getHours() < 10 ? '0' + nowTime.getHours() : nowTime.getHours()
	let minute =
		nowTime.getMinutes() < 10
			? '0' + nowTime.getMinutes()
			: nowTime.getMinutes()
	let second =
		nowTime.getSeconds() < 10
			? '0' + nowTime.getSeconds()
			: nowTime.getSeconds()
	if (!type) {
		return `${Year}-${month}-${date} ${hour}:${minute}:${second}`
	}
	if (type == 'ymd') {
		return `${Year}-${month}-${date}`
	}
}

function toFixedZ(str, count) {
	if (!str) {
		return '----'
	}
	let counts = count ? count : 2
	let number = Number(str)
	return number.toFixed(counts) // 默认返回两位小数点
}

let fnc = {
	getImgUrl,
	getTimeFormat,
	toFixedZ,
}

export default fnc
